package com.hugedata.cdnserver.util;

import java.util.Comparator;

public class CompareUtil implements Comparator<Object>
{
    public int compare(Object o0, Object o1)
    {
        Seed seed0 = null;
        Seed seed1 = null;
        if (o0 instanceof Seed && o1 instanceof Seed)
        {
            seed0 = (Seed) o0;
            seed1 = (Seed) o1;
        }
        else
        {
            return -2;
        }

        String icp0 = seed0.getIcp();
        String[] split = icp0.split("\t");
        if (split.length == 2)
        {
            icp0 = split[0];
        }
        String icp1 = seed1.getIcp();
        String[] split1 = icp1.split("\t");
        if (split1.length == 2)
        {
            icp1 = split1[0];
        }

        if (null != icp0 && null != icp1)
        {
            if (icp1.length() > icp0.length())
            {
                return 1;
            }
            else if (icp1.length() < icp0.length())
            {
                return -1;
            }
            else
            {
                return 0;
            }
        }
        return 0;
    }
}
